package wechat

import (
	"errors"
)

var appCache = map[string]*AppClient{}

func SetAppClient(key string, conf *AppConfig) error {
	var (
		ac  *AppClient
		err error
	)
	if appCache[key] != nil {
		return errors.New("key existed")
	}
	ac, err = NewAppClient(key, conf)
	if err != nil {
		return err
	}
	appCache[key] = ac
	return nil
}

func GetAppClient(key string) *AppClient {
	return appCache[key]
}
